package com.assignwork.modules.pc;

import com.assignwork.dto.ShipForecastSearchDTO;
import com.assignwork.dto.pcplan.*;
import com.assignwork.entity.pc.PcShipRealWriting;
import com.assignwork.modules.pc.service.pc.IPcShipRealWritingService;
import com.assignwork.vo.ShipVoyagePageVO;
import com.assignwork.vo.pc.PcShipPlanVo;
import com.assignwork.vo.pc.PcShipRealWritingPageVo;
import com.assignwork.vo.pc.PcShipRealWritingVo;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * @ClassName PcShipRealWritingController
 * @Description
 * @Author slPcShipRealWritingSubmitDto
 * @Date 2023/12/27 10:21
 */

@RestController
@RequestMapping("shipRealWriting")
@AllArgsConstructor
public class PcShipRealWritingController {
    private IPcShipRealWritingService service;

    @PostMapping("/submit")
    @ApiOperationSupport(order = 1)
    @ApiOperation(value = "新增或修改", notes = "传入entity")
    public R<Boolean> submitPcShipRealWriting(@Valid @RequestBody PcShipRealWritingSubmitDto submitDTO) {
        return R.status(service.submitPcShipRealWriting(submitDTO));
    }

    @GetMapping("/list")
    @ApiOperationSupport(order = 2)
    @ApiOperation(value = "列表", notes = "传入dto")
    public R<List<PcShipRealWritingVo>> selectPcShipRealWritingList(PcShipRealWritingSearchDto dto) {
        List<PcShipRealWritingVo> data = service.selectPcShipRealWritingList(dto);
        return R.data(data);
    }
    @GetMapping("/easyList")
    @ApiOperationSupport(order = 2)
    @ApiOperation(value = "列表", notes = "传入dto")
    public R<List<PcShipRealWritingVo>> selectPcShipRealWritingEasyList(PcShipRealWritingSearchDto dto) {
        List<PcShipRealWritingVo> data = service.selectPcShipRealWritingEasyList(dto);
        return R.data(data);
    }

    @GetMapping("/pcShipRealWritingPage")
    @ApiOperationSupport(order = 3)
    @ApiOperation(value = "分页", notes = "传入dto")
    public R<IPage<PcShipRealWritingPageVo>> shipVoyagePage(ShipForecastSearchDTO dto, Query query) {
        return R.data(service.selectPcShipRealWritingPage(dto, Condition.getPage(query)));
    }

    @PostMapping("/removePcShipRealWriting")
    @ApiOperationSupport(order = 4)
    @ApiOperation(value = "删除", notes = "传入id")
    public R<Boolean> remove(@ApiParam(value = "主键集合", required = true) @RequestParam String id) {
        return R.status(service.deleteLogic(Func.toLongList(id)));
    }
    @PostMapping("/syncPcShipRealWriting")
    @ApiOperationSupport(order = 5)
    @ApiOperation(value = "同步交接班", notes = "传入同步字段,shipID")
    public R<Boolean> syncPcShipRealWriting(@Valid @RequestBody SyncPcShipRealWritingDto dto) {
        return R.status(service.syncPcShipRealWriting(dto));
    }

    @PostMapping("/clearSelectedPcShipRealWriting")
    @ApiOperationSupport(order = 6)
    @ApiOperation(value = "清除写实已选图片", notes = "传入同步字段,shipID")
    public R<Boolean> clearSelectedPcShipRealWriting(@Valid @RequestBody SyncPcShipRealWritingDto dto) {
        return R.status(service.clearSelectedPcShipRealWriting(dto));
    }
}
